 Ext.ux.ThemeCycleButton = Ext.extend(Ext.CycleButton, {  
     /**   
      * file 你的css名称   
      * text 下拉框的名称  
      * iconCls 设置图标css  
      */                                    
   
     cssItems:[   
         {file: 'ext-all.css', text: '蓝色月影',  iconCls: 'icon-blue-theme'},  
				 {file: 'xtheme-gray.css', text: '银灰月夜', iconCls: 'icon-gray-theme'},   
         {file: 'xtheme-darkgray.css', text: '灰暗天幕', iconCls: 'icon-darkgray-theme'},   
         {file: 'xtheme-green.css', text: '绿色芬芳', iconCls: 'icon-green-theme'},   
         {file: 'xtheme-olive.css', text: '橄榄心情', iconCls: 'icon-olive-theme'},					 
				 {file: 'xtheme-calista.css', text: '缤纷花园', iconCls: 'icon-calista-theme'},   
         {file: 'xtheme-pink.css', text: '粉色回忆', iconCls: 'icon-pink-theme'},   
         {file: 'xtheme-purple.css', text: '紫色诱惑', iconCls: 'icon-purple-theme'},
				 {file: 'xtheme-slate.css', text: '深蓝海洋', iconCls: 'icon-slate-theme'},
				 {file: 'xtheme-indigo.css', text: '靛青苍穹', iconCls: 'icon-indigo-theme'},   
         {file: 'xtheme-midnight.css', text: '午夜星空', iconCls: 'icon-midnight-theme'},						
				 {file: 'xtheme-black.css', text: '黑色物语', iconCls: 'icon-black-theme'},   
         {file: 'xtheme-slickness.css', text: '黑色诙谐', iconCls: 'icon-slickness-theme'}   
     ],  
   
     themeVar:'style',   
     headVar: 'head',   
     //cssPath			
     cssPath: '../../extSDK/resources/',       
   
     initComponent: function() {   
         Ext.apply(this, {
             showText: true,   
             prependText: '',
             items: this.cssItems
         });

		//Added by Albert on 20090720
		if(!Ext.isIE && !Ext.isIE6 && !Ext.isIE7 && !Ext.isIE8){
			Ext.util.CSS.swapStyleSheet("patch_css", '../../extSDK/resources/otherCss/css/ext-patch.css');//不是IE浏览器则打一个css补丁
		}

		var cookiesArr = document.cookie.split(";");
		var cssName = "";
		for(var i=0; i<cookiesArr.length; i++){
			var arr = cookiesArr[i].split("=");
			if(arr[0] == "css"){
				cssName = arr[1];
				break;
			}
		}
		if(cssName != ""){
			 for(var i=0; i<this.items.length;i++){   
				 if (this.items[i].file == cssName){   
					 this.items[i].checked = true;   
					 this.changeHandler(this, this.items[i]);   
					 break;
				 }   
			 }			 
		}
		else{
			this.items[0].checked = true;
			//this.changeHandler(this, this.items[0]); //默认为ext-all.css ，由于html页已经引用了，因此不必再设置
		}
		//End of addition

         Ext.ux.ThemeCycleButton.superclass.initComponent.apply(this, arguments); 
     },
     
     changeHandler: function(o, i){
		//Added by Albert on 20090714
		if(i.file == 'ext-all.css'){
			Ext.util.CSS.swapStyleSheet(this.themeVar, this.cssPath + '/css/' + i.file);
			//必须保证ext-all.css总是位于ext-patch.css的前面
			if(!Ext.isIE && !Ext.isIE6 && !Ext.isIE7 && !Ext.isIE8){
				Ext.util.CSS.swapStyleSheet("patch_css", '../../extSDK/resources/otherCss/css/ext-patch.css');//不是IE浏览器则打一个css补丁
			}
		}
		else{
			Ext.util.CSS.swapStyleSheet(this.themeVar, this.cssPath + 'otherCss/css/' + i.file);
		}

		var date=new Date();
		date.setTime(date.getTime() + 30*24*3066*1000);
		document.cookie="css=" + i.file + ";expires=" + date.toGMTString();
		//End of addition

         if(Ext.getCmp('viewport')){
             Ext.getCmp('viewport').layout.center.panel.setSize(Ext.getCmp('viewport').layout.center.getSize().width + 1);
             Ext.getCmp('viewport').doLayout();
             Ext.getCmp('viewport').layout.center.panel.setSize(Ext.getCmp('viewport').layout.center.getSize().width - 1);
             Ext.getCmp('viewport').doLayout();
         }
     } 
 });
 Ext.reg('themecyclebutton', Ext.ux.ThemeCycleButton); 